﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {

            Hashtable hashtable = new Hashtable();
            hashtable.Add(1, "活着");
            hashtable.Add(2, "骆驼祥子");
            hashtable.Add(3, "人生");
            hashtable.Add(4, "兄弟");
            hashtable.Add(5, "边城");
            foreach (DictionaryEntry imem in hashtable)
            {
                int key = (int)imem.Key;
                string val = imem.Value.ToString();
                Console.WriteLine("书籍的号码为：{0}，书籍的名称为：{1}", key, val);
            }
            Console.WriteLine("请输入你所看书籍号码：");
            int id = int.Parse(Console.ReadLine());
            bool flag = hashtable.ContainsKey(id);
            Console.WriteLine("书籍如下：");

            if (flag)
            {
                Console.WriteLine("你查找的图书名称：{0}", hashtable[id].ToString());
            }
            else
            {
                Console.WriteLine("你查找的书籍不存在！");
            }
        }
    }
}